﻿using KayakMes.Common.Dtos.ProductControlDTO;
using KayakMes.Common.Result;
using KayakMes.ProductControl.Application.Services;
using KayakMes.ProductControl.Domain.Entity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Yitter.IdGenerator;

namespace KayakMes.ProductControl.API.Controllers
{
    /// <summary>
    /// 产品管理—盘号信息控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ReelNumberController : ControllerBase
    {
        private readonly IProductService productService;

        public ReelNumberController(IProductService productService)
        {
            this.productService = productService;
        }
        #region 产品管理—盘号操作
        /// <summary>
        /// 添加盘号信息
        /// </summary>
        /// <param name="reelNumber">盘号实体</param>
        /// <returns>返回操作结果以及受影响行数</returns>
        [HttpPost]
        public ApiResult<int> AddReelNumber(ReelNumberModel reelNumber)
        {
            return productService.AddReelNumber(reelNumber);
        }
        /// <summary>
        /// 获取所有盘号信息以及分页查询
        /// </summary>
        /// <param name="dto">盘号Dto类</param>
        /// <returns>返回操作结果以及受影响行数</returns>
        [HttpGet]
        public ApiPaging<ReelNumberModel> GetAllReelNumber(ReelNumberDto dto)
        {
            return productService.GetAllReelNumber(dto);
        }
        /// <summary>
        /// 通过Id获取盘号信息
        /// </summary>
        /// <param name="Id">盘号Id</param>
        /// <returns>返回操作结果以及受影响行数</returns>
        [HttpGet]
        public ApiResult<ReelNumberModel> GetReelNumber(long Id)
        {
            return productService.GetReelNumber(Id);
        }
        /// <summary>
        /// 更新盘号信息
        /// </summary>
        /// <param name="reelNumber">盘号实体</param>
        /// <returns>返回操作结果以及受影响行数</returns>
        [HttpPut]
        public ApiResult<int> UpdateReelNumber(ReelNumberModel reelNumber)
        {
            return productService.UpdateReelNumber(reelNumber);
        }
        /// <summary>
        /// 删除盘号信息
        /// </summary>
        /// <param name="Id">盘号ID</param>
        /// <returns>返回操作结果以及受影响行数</returns>
        [HttpDelete]
        public ApiResult<int> DelReelNumber(long Id)
        {
            return productService.DelReelNumber(Id);
        }
        #endregion
    }
}
